# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from fastapi import APIRouter, Depends
from hypertext import R, response_json
from apps.admin.schemas.users import group_schema as schema
from apps.admin.service.users.group_service import UserGroupService

router = APIRouter(prefix="/group", tags=["用户分组"])


@router.get("/whole", summary="全部用户分组", response_model=R[schema.UserGroupWholeVo])
@response_json
async def whole():
    return await UserGroupService.whole()


@router.get("/lists", summary="用户分组列表", response_model=R[schema.UserGroupListVo])
@response_json
async def lists(params: schema.UserGroupSearchIn = Depends()):
    return await UserGroupService.lists(params)


@router.get("/detail", summary="用户分组详情", response_model=R[schema.UserGroupDetailVo])
@response_json
async def detail(params: schema.UserGroupDetailIn = Depends()):
    return await UserGroupService.detail(params.id)


@router.post("/add", summary="用户分组新增", response_model=R)
@response_json
async def add(params: schema.UserGroupAddIn):
    return await UserGroupService.add(params)


@router.post("/edit", summary="用户分组编辑", response_model=R)
@response_json
async def add(params: schema.UserGroupEditIn):
    return await UserGroupService.edit(params)


@router.post("/delete", summary="用户分组删除", response_model=R)
@response_json
async def delete(params: schema.UserGroupDeleteIn):
    return await UserGroupService.delete(params.id)
